package control;

import java.io.File;
import java.io.IOException;
import java.sql.SQLException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.Map;
import java.util.StringTokenizer;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import model.service.AdminService;
import model.vo.movie.CountryVO;
import model.vo.movie.GenreVO;
import model.vo.movie.MovieGradeInfo;
import model.vo.movie.MovieVO;
import model.vo.reservation.ScreeningMovieVO;
import model.vo.theater.LocalInfoVO;
import model.vo.theater.PlayRoomTypeVO;
import model.vo.theater.PlayRoomVO;
import model.vo.theater.TheaterVO;

import org.springframework.web.multipart.MultipartFile;
import org.springframework.web.servlet.ModelAndView;
import org.springframework.web.servlet.mvc.multiaction.MultiActionController;

public class AdminController extends MultiActionController {
	private AdminService adminService;
	private String path;
	public AdminController(AdminService adminService, String path) {
		super();
		this.adminService = adminService;
		this.path=path;
	}

	/**
	 *  layout2 - admin 로그인
	 */
	public ModelAndView home_main_admin(HttpServletRequest request, HttpServletResponse response){
		System.out.println("home_main_admin join..");
		return new ModelAndView("home_main_admin");
	}
	/**
	 *  layout1 - 회원가입
	 */
	public ModelAndView reg_terms(HttpServletRequest request, HttpServletResponse response){
		System.out.println("register join..");
		return new ModelAndView("reg_terms.member");
	}
	public ModelAndView main_admin(HttpServletRequest request, HttpServletResponse response){
		System.out.println("main_admin join.."); 
		return new ModelAndView("main.admin");
	}
	/**
	 *	관리자메뉴 - 영화등록을 위한 setting page
	 */
	public ModelAndView movie_admin(HttpServletRequest request, HttpServletResponse response){
		System.out.println("movie_admin join.."); 
		Map map = new HashMap();		
		try {
			map.put("genre", adminService.getGenreInfo()); //장르정보
			map.put("country",adminService.getCountryInfo());	//나라정보
			map.put("grade", adminService.getGradeInfo()); //등급정보
		} catch (SQLException e) {
			e.printStackTrace();
		}
		return new ModelAndView("movie.admin","info",map);
	}
	/**
	 * 관리자메뉴 - 영화관리 - 영화등록
	 * 최초영화 등록시에, statics table에도 insert 시켜준다. 
	 * @throws InterruptedException 
	 */
	public ModelAndView registerMovie(HttpServletRequest request, HttpServletResponse response,MovieVO movieVO){
		movieVO.setGenreVO(new GenreVO(Integer.parseInt(request.getParameter("genre_no"))));
		movieVO.setCountryVO(new CountryVO(Integer.parseInt(request.getParameter("country_no"))));
		movieVO.setMovieGradeInfoVO(new MovieGradeInfo(Integer.parseInt(request.getParameter("movie_grade_no"))));
		MultipartFile mfile=movieVO.getUploadFile();
		try {
			//1. 먼저 movie 등록한다.
			adminService.registerMovie(movieVO);
			//2. 이제 포스터 등록한다.
			 if(mfile.isEmpty()==false||mfile.getOriginalFilename()!=null){
				String fileName=mfile.getOriginalFilename();	//원래 파일이 있었다면 저장.	
				movieVO.setOrgfileName(fileName);
				String newfilename=movieVO.getMovie_no()+".jpg";
				movieVO.setNewfileName(newfilename);
				File copyFile=new File(path+newfilename);
				mfile.transferTo(copyFile);
				request.setAttribute("register", "success");
			 }
			Thread.sleep(5000);
		} catch (SQLException e) {
			e.printStackTrace();
			System.out.println("이미 등록된 영화 입니다");
			request.setAttribute("register", "fail");
		} catch (IllegalStateException e) {
			e.printStackTrace();
			request.setAttribute("register", "fail");
		} catch (IOException e) {
			e.printStackTrace();
			request.setAttribute("register", "fail");
		} catch (InterruptedException e) {
			e.printStackTrace();
			request.setAttribute("register", "fail");
		}				
		return new ModelAndView("register_movie_ok.admin","vo",movieVO);
	}
	/**
	 *	관리자메뉴 - 영화관리 -영화목록
	 */
	public ModelAndView movie_list_admin(HttpServletRequest request, HttpServletResponse response){
		System.out.println("movie_list_admin join..");
		ArrayList<MovieVO> list=null;
		try {
			list = adminService.getMovieInfo();
			System.out.println("영화 총 리스트 : "+list);
		} catch (SQLException e) {
			e.printStackTrace();
		}
		return new ModelAndView("movie_list.admin","info",list);
	}
	/**
	 *	관리자메뉴 - 영화관등록 페이지로 이동 : 신일
	 */
	public ModelAndView theater_regPage_move(HttpServletRequest request, HttpServletResponse response){
		ArrayList<LocalInfoVO> lList=new ArrayList<LocalInfoVO>();
		System.out.println("test....sin");
		try {
			lList=adminService.getLocalInfo();
		} catch (SQLException e) {
			e.printStackTrace();
		}
		System.out.println("theater_admin join..theater_regPage_move");
		return new ModelAndView("theater.admin","loc_list",lList);
	}
	/**
	 *	관리자메뉴 - 영화관수정 페이지로 이동 : 신일
	 */
	public ModelAndView theater_modifyPage_move(HttpServletRequest request, HttpServletResponse response){
		ArrayList<LocalInfoVO> lList=new ArrayList<LocalInfoVO>();
		try {
			lList=adminService.getLocalInfo();
		} catch (SQLException e) {
			e.printStackTrace();
		}
		System.out.println("theater_admin join..theater_modifyPage_move");
		return new ModelAndView("theater_modify.admin","loc_list",lList);
	}
	/**
	 * 관리자메뉴 - 영화관수정을 위한 영화관 정보 로딩 : 신일
	 */
	public ModelAndView getTheaterInfoByTNO(HttpServletRequest request, HttpServletResponse response, TheaterVO tvo){
		TheaterVO rvo=new TheaterVO();
		try {
			rvo=adminService.getTheaterVObyTNo(tvo);
			rvo.setLocalInfoVO(tvo.getLocalInfoVO());
		} catch (Exception e) {
			e.printStackTrace();
		}
		System.out.println("theater_admin join..getTheaterInfoByTNO");
		return new ModelAndView("JsonView","tvo",rvo);
	}
	/**
	 *	관리자메뉴 - 영화관 등록 후 상영관 입력을 위한 정보를 로딩 : 신일
	 */
	public ModelAndView theater_reg(HttpServletRequest request, HttpServletResponse response, TheaterVO tvo){
		int loc_no=Integer.parseInt(request.getParameter("localInfoVO.loc_no"));
		ArrayList newPrNoList=new ArrayList();
		ArrayList regPrNoList=new ArrayList();
		ArrayList<PlayRoomVO> prList=new ArrayList<PlayRoomVO>();
		ArrayList<PlayRoomTypeVO> prTypeList=new ArrayList<PlayRoomTypeVO>();
		Map map=new HashMap();
		
		LocalInfoVO loc_info=new LocalInfoVO();
		loc_info.setLoc_no(loc_no);
		tvo.setLocalInfoVO(loc_info);
		try {
			adminService.registerTheater(tvo);
			//새로 입력가능한 상영관 번호 연산하는 부분 : 상영관 리스트를 받아오는게 있어서 여기에 코딩...;;
			prList=adminService.getPlayRoomVOList(tvo);
			prTypeList=adminService.getPlayRoomTypeVO();
			for(int i=1;i<21;i++){
				newPrNoList.add(i);
			}
			for(int i=0;i<prList.size();i++){
				regPrNoList.add(prList.get(i).getPlay_room_no());
			}
			for(int i=0;i<newPrNoList.size();i++){
				for(int j=0;j<regPrNoList.size();j++){
					if(regPrNoList.get(j).toString().equals(newPrNoList.get(i).toString())){
						newPrNoList.remove(i);
					}
				}
			}
		} catch (SQLException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		map.put("tvo", tvo);
		map.put("prNoList", newPrNoList);
		map.put("prTypeList", prTypeList);
		System.out.println("theater_admin join..theater_reg.."+map);
		return new ModelAndView("JsonView","map",map);
	}
	/**
	 *	관리자메뉴 - 영화관 수정 : 신일
	 *: 입력테이블에 새롭게 수정된 정보를 반환하고 상영관 리스트와 새로 입력가능한 상영관 번호를 로딩 
	 */
	public ModelAndView theater_modify(HttpServletRequest request, HttpServletResponse response, TheaterVO tvo){
		ArrayList<PlayRoomVO> prList=new ArrayList<PlayRoomVO>();
		ArrayList<PlayRoomTypeVO> prTypeList=new ArrayList<PlayRoomTypeVO>();
		ArrayList newPrNoList=new ArrayList();
		ArrayList regPrNoList=new ArrayList();
		Map map=new HashMap();
		try {
			adminService.modifyTheaterInfo(tvo);
			prList=adminService.modifyTheaterInfo(tvo);
			prTypeList=adminService.getPlayRoomTypeVO();
			//새로 입력가능한 상영관 번호 연산하는 부분 
				for(int i=1;i<21;i++){
					newPrNoList.add(i);
				}
				for(int i=0;i<prList.size();i++){
					regPrNoList.add(prList.get(i).getPlay_room_no());
				}
				for(int i=0;i<newPrNoList.size();i++){
					for(int j=0;j<regPrNoList.size();j++){
						if(regPrNoList.get(j).toString().equals(newPrNoList.get(i).toString())){
							newPrNoList.remove(i);
						}
					}
				}
			map.put("tvo", tvo);
			map.put("prList", prList);
			map.put("prNoList", newPrNoList);
			map.put("prTypeList", prTypeList);
		} catch (SQLException e) {
			e.printStackTrace();
		}
		System.out.println("theater_admin theater_modify join.."+map);
		return new ModelAndView("JsonView","map",map);
	}
	/**
	 *	관리자메뉴 - 상영관등록 : 신일
	 */
	public ModelAndView playRoom_reg(HttpServletRequest request, HttpServletResponse response, PlayRoomVO pvo){
		ArrayList<PlayRoomVO> prList=new ArrayList<PlayRoomVO>();
		ArrayList newPrNoList=new ArrayList();
		ArrayList regPrNoList=new ArrayList();
		TheaterVO tvo=new TheaterVO();
		tvo.setTheater_no(pvo.getTheaterVO().getTheater_no());
		Map map=new HashMap();
		
		try {
			adminService.registerPlayRoom(pvo);
			prList=adminService.getPlayRoomVOList(tvo);
			for(int i=1;i<21;i++){
				newPrNoList.add(i);
			}
			for(int i=0;i<prList.size();i++){
				regPrNoList.add(prList.get(i).getPlay_room_no());
			}
			for(int i=0;i<newPrNoList.size();i++){
				for(int j=0;j<regPrNoList.size();j++){
					if(regPrNoList.get(j).toString().equals(newPrNoList.get(i).toString())){
						newPrNoList.remove(i);
					}
				}
			}
		} catch (SQLException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		map.put("pvo", pvo);
		map.put("prNoList", newPrNoList);
		System.out.println("theater_admin join..playRoom_reg"+map);
		return new ModelAndView("JsonView","map",map);
	}
	/**
	 * 관리자 메뉴 - 상영관삭제  : 신일
	 */
	public ModelAndView playRoom_del(HttpServletRequest request, HttpServletResponse response){
		ArrayList<String> list=getStringFormat(request.getParameter("delList"));
		Map map=new HashMap();
		ArrayList<String> sm=new ArrayList<String>();
		ArrayList<String> fm=new ArrayList<String>();
		int r=0;
		for (String playRoomNo : list) {
	         int i=Integer.parseInt(playRoomNo);
	         try {
				r=adminService.getPlayRoomNoByPlayRoomUniqNo(i);	
				adminService.delPlayRoom(i);
				sm.add(Integer.toString(r));
				map.put("success",sm);
			} catch (SQLException e) {
				try {
					r=adminService.getPlayRoomNoByPlayRoomUniqNo(i);
					fm.add(Integer.toString(r));;
					map.put("fal", fm);
				} catch (SQLException e1) {
					e1.printStackTrace();
				}
			}
	      }
		System.out.println("theater_admin join..playRoom_del"+map);
		return new ModelAndView("JsonView","delResult",map);
	}
	/**
	 * 영화관 관리-.screening movie Form
	 */
	public ModelAndView regScreeningMovieForm(HttpServletRequest request, HttpServletResponse response){
		System.out.println("regScreeningMovieForm join..");
		Map map =new HashMap();
		try {
			map.put("local",adminService.getLocalInfo()); //지역정보
			map.put("movie", adminService.getMovieInfo()); //영화정보
			map.put("screening_movie_list", adminService.getScreeningMovieList());
		} catch (SQLException e) {
			e.printStackTrace();
		}
		return new ModelAndView("screening.admin","info",map);
	}
	/**
	 * 영화관 관리 - screening movie form 에서 localList
	 */
	public ModelAndView getTheaterListByLocalNo(HttpServletRequest request, HttpServletResponse response){
		System.out.println("getTheaterListByLocalNo");
		int loc_no =Integer.parseInt(request.getParameter("loc_no"));
		ArrayList<HashMap> theaterList=null;
		try {
			theaterList = adminService.getTheaterListByLocalNo(loc_no);
		} catch (SQLException e) {
			System.out.println("없는 지역 입니다.");
			e.printStackTrace();
		}
		return new ModelAndView("JsonView","list",theaterList);
	}
	/**
	 * 영화관 관리 = screening movie - 영화 선택시 그 영화의 공식 개봉일
	 */
	public ModelAndView getPublicDayByMovieNo(HttpServletRequest request, HttpServletResponse response){
		int movie_no = Integer.parseInt(request.getParameter("movie_no"));
		ArrayList<HashMap> pday = null;
		try {
			pday= adminService.getPublicDayByMovieNo(movie_no);
			System.out.println(pday);
		} catch (SQLException e) {
			e.printStackTrace();
		}
		return new ModelAndView("JsonView","pday",pday);
	}
	/**
	 * 영화관 관리- screening movie 등록
	 */
	public ModelAndView regScreeningMovie(HttpServletRequest request, HttpServletResponse response,ScreeningMovieVO movieVO){
		Map map =new HashMap();
		System.out.println("regScreeningMovie join..");
		movieVO.setTheaterVO(new TheaterVO(Integer.parseInt(request.getParameter("theater_no"))));
		movieVO.setMovieVO(new MovieVO(Integer.parseInt(request.getParameter("movie_no"))));
		try {
			adminService.regScreeningMovie(movieVO);
			map.put("local",adminService.getLocalInfo()); //지역정보
			map.put("movie", adminService.getMovieInfo()); //영화정보
			map.put("screening_movie_list",adminService.getScreeningMovieList()); //screening movie list
		} catch (SQLException e) {
			e.printStackTrace();
		}
		return new ModelAndView("screening.admin","info",map);
	}
	/**
	 * 입력받은 String 문자열을 콤마(,) 기준으로 Format해서 list에 담는 메서드
	 * ex) 1,2,10,11
	 * list.add(1); list.add(2); list.add(10); list.add(11);  
	 */
	public ArrayList<String> getStringFormat(String str){
		ArrayList<String> list = new ArrayList();
		StringBuffer sb = new StringBuffer(str);
		while(true){
			int index = sb.indexOf(",");
			if(index==-1)
				break;
			list.add(sb.substring(0, index));
			sb.delete(0, index+1);
		}
		list.add(sb.toString());
		return list;
	}
	/** 
	 *	관리자메뉴 - 상영표관리 - 상영표관리
	 * 상영표 등록시 screening_movie 테이블에 있는 등록가능한
	 * 영화,지역,영화관 목록들을 가져온다.
	 * @throws SQLException 
	 */
	public ModelAndView timetable_admin(HttpServletRequest request, HttpServletResponse response) {
		System.out.println("timetable_admin join..  : ");
		HashMap map = adminService.timetable_admin_info(request.getParameter("pageNo"));
		System.out.println(map);
		return new ModelAndView("timetable.admin","map",map);
	}
	/**
	 *	관리자메뉴 - 상영표관리 - 상영표관리
	 * 선택삭제시 선택한 list 를 StringFormat으로 ArrayList에 담고 삭제한다.
	 */
	public ModelAndView timetableDelete(HttpServletRequest request, HttpServletResponse response) {
		System.out.println("timetableDelete join.. list : "+request.getParameter("list"));
		ArrayList<String> list = getStringFormat(request.getParameter("list"));
		System.out.println("delete list : " + list);
		HashMap map = adminService.delTimeTable(list);
		return new ModelAndView("JsonView", "map", map);
	}
	/**
	 * 관리자메뉴 - 상영표관리 - 상영표관리
	 * 삭제가능한 모든 상영스케쥴을 삭제한다.
	 */
	public ModelAndView timetableAllDelete(HttpServletRequest request, HttpServletResponse response) {
		System.out.println("timetableAllDelete join..");
		ArrayList<String> list = adminService.getAllTimeTableNo();
		System.out.println("delete list : " + list);
		HashMap map = adminService.delTimeTable(list);
		return new ModelAndView("JsonView", "map", map);
	}
	/** 
	 *	관리자메뉴 - 상영표관리 - 상영표관리
	 * 상영표 등록시 (영화선택)에 따라서
	 * screening_movie 테이블에 있는 상영 가능한 (지역정보)를 가져온다. 
	 */
	public ModelAndView getLocalAsMovieNo(HttpServletRequest request, HttpServletResponse response) {
		System.out.println("getOthersAsMovieNo join.."+request.getParameter("movie_no"));
		HashMap map = adminService.getLocalAsMovieNo(request.getParameter("movie_no"));
		System.out.println(map);
		return new ModelAndView("JsonView","map",map);
	}
	/** 
	 *	관리자메뉴 - 상영표관리 - 상영표관리
	 * 상영표 등록시 (지역선택)에 따라서
	 * screening_movie 테이블에 있는 상영 가능한 (영화관정보)를 가져온다. 
	 */
	public ModelAndView getTheaterAsLocalNoAndMovleNo(HttpServletRequest request, HttpServletResponse response) {
		String movie_no = request.getParameter("movie_no");
		String local_no = request.getParameter("local_no");
		HashMap map = new HashMap();
		map.put("movie_no",movie_no);
		map.put("local_no",local_no);
		System.out.println("getTheaterAsLocalNoAndMovleNo join..map : "+map);
		HashMap map2 = adminService.getTheaterAsLocalNoAndMovleNo(map) ;
		System.out.println(map2);
		return new ModelAndView("JsonView","map",map2);
	}
	/** 
	 *	관리자메뉴 - 상영표관리 - 상영표관리
	 * 상영표 등록시 (영화관, 영화선택)에 따라서
	 * play_room 테이블에 있는 해당 영화관의 (상영관목록과 등록가능시간)을 가져온다.
	 */
	public ModelAndView getPlayRoomAndPossibleDateAsTheaterNoAndMovieNo(HttpServletRequest request, HttpServletResponse response) {
		System.out.println("getPlayRoomAsTheaterNo join..theater_no : "+request.getParameter("theater_no")+", movie_no : "+request.getParameter("movie_no")+", local_no : "+request.getParameter("local_no"));
		HashMap map = new HashMap();
		HashMap queryMap = new HashMap();
		queryMap.put("theater_no", request.getParameter("theater_no"));
		queryMap.put("movie_no", request.getParameter("movie_no"));
		queryMap.put("local_no", request.getParameter("local_no"));
		map.put("play_room",adminService.getPlayRoomAsTheaterNo(request.getParameter("theater_no")));
		map.put("possible_date",adminService.getPossibleDateAsMovieNo(queryMap));
		map.put("tlist",adminService.getTimeTableAsMovieNoAndLocalNoAndTheaterNo(queryMap));
		System.out.println(map);
		return new ModelAndView("JsonView","map",map);
	}
	/** 
	 *	관리자메뉴 - 상영표관리 - 상영표관리
	 * 상영표 등록시 입력받은 정보를 time_table 에 insert
	 */
	public ModelAndView timeTableRegister(HttpServletRequest request, HttpServletResponse response) {
		HashMap map = new HashMap();
		map.put("movie_no", request.getParameter("movie"));
		map.put("theater_no", request.getParameter("theater"));
		map.put("play_room_no", request.getParameter("play_room"));
		map.put("day",request.getParameter("day"));
		map.put("hour",request.getParameter("hour"));
		map.put("minute",request.getParameter("minute"));
		System.out.println("timeTableRegister join.. map : "+map);
		adminService.timeTableRegister(map);
		HashMap map2 = adminService.timetable_admin_info(request.getParameter("pageNo"));
		return new ModelAndView("timetable.admin","map",map2);
	}
	/** 
	 *	관리자메뉴 - 상영표관리 - 상영표관리
	 * 상영표 등록시 입력받은 정보를 time_table 에 하루치 insert
	 */
	public ModelAndView timeTableOneDayRegister(HttpServletRequest request, HttpServletResponse response) {
		HashMap map = new HashMap();
		map.put("movie_no", request.getParameter("movie"));
		map.put("theater_no", request.getParameter("theater")); 
		map.put("play_room_no", request.getParameter("play_room"));
		map.put("day",request.getParameter("day"));
		map.put("hour",request.getParameter("hour"));
		map.put("minute",request.getParameter("minute"));
		System.out.println("timeTableOneDayRegister join.. map : "+map);
		adminService.timeTableOneDayRegister(map);
		HashMap map2 = adminService.timetable_admin_info(request.getParameter("pageNo"));
		return new ModelAndView("timetable.admin","map",map2);
	}
	
	/** 
	 *	관리자메뉴 - 상영표관리 - 상영표관리
	 * 상영관번호 선택시에 ajax로 해당 상영관에 time_table을 보여줌.
	 */
	public ModelAndView getTimeTableAsAllNo(HttpServletRequest request, HttpServletResponse response){
		HashMap map = new HashMap();
		map.put("movie_no", request.getParameter("movie_no"));
		map.put("theater_no", request.getParameter("theater_no"));
		map.put("play_room_no", request.getParameter("play_room_no"));
		map.put("local_no",request.getParameter("local_no"));
		System.out.println("timetable_modify_admin join.. map : "+map);
		return new ModelAndView("JsonView","tlist",adminService.getTimeTableAsAllNo(map));
	}
	/**
	 *	관리자메뉴 - 회원 수정/삭제
	 */
	public ModelAndView member_modify_admin(HttpServletRequest request, HttpServletResponse response){
		System.out.println("member_modify_admin join..");
		return new ModelAndView("member_modify.admin");
	}
	/** 5/9아영
	 * 관리자메뉴 - 박스오피스form - update
	 *  1. 먼저 reservation table의 정보를 추출 : movie_no, total_member 계산
	 *  2. 계산정보를 statics table에 update
	 */
	public ModelAndView updateBoxOffice(HttpServletRequest request, HttpServletResponse response){
		System.out.println("아영 : updateBoxOffice");
		ArrayList<HashMap> list = null;
		try {
			adminService.updateBoxOffice();
			list = adminService.getBoxOfficeList();			
		} catch (SQLException e) {
			e.printStackTrace();
		}
		return new ModelAndView("JsonView","list",list);
	}
	

	/**
	 * 영화관리 - 영화목록 - 영화세부정보 보기
	 */
	public ModelAndView showMovieDetail(HttpServletRequest request, HttpServletResponse response){
		int movie_no=Integer.parseInt(request.getParameter("movie_no"));
		MovieVO vo=null;
		try {
			 vo = adminService.showMovieDetail(movie_no);			
		} catch (SQLException e) {
			System.out.println("등록되지 않은 영화입니다.");
			e.printStackTrace();
		}
		return new ModelAndView("movie_detail.admin","vo",vo);
	}
	/**
	 *	관리자메뉴 - 박스오피스 form--5/9아영추가사항
	 */
	public ModelAndView statics_admin(HttpServletRequest request, HttpServletResponse response){
		System.out.println("statics_admin join..");
		ArrayList<HashMap> list=null;
		try {
			list = adminService.getBoxOfficeList();
			System.out.println(list);
		} catch (SQLException e) {
			e.printStackTrace();
		}
		return new ModelAndView("statics.admin","list",list);
	}
	/** 5/9아영
	 * 관리자메뉴 - 박스오피스form - update
	 *  1. 먼저 reservation table의 정보를 추출 : movie_no, total_member 계산
	 *  2. 계산정보를 statics table에 update
	 */

	public ModelAndView move_sitemap(HttpServletRequest request, HttpServletResponse response){
		System.out.println("move_sitemap... 사이트맵으로 이동");
		return new ModelAndView("sitemap.ex");
	}
	/**
	 * 영화관리 - screening movie 삭제-5/11아영
	 */
	public ModelAndView screeningMovieDel(HttpServletRequest request, HttpServletResponse response){
		//String Format!!!!  - movie_no,theater_no		
		ArrayList<String> list = getStringFormat(request.getParameter("list"));		
		try {
			System.out.println("삭제리스트:"+list);
			String no="";
			for(String str:list){
				no+=str+"/";
			}
			System.out.println("원래순서 : "+no); //하나씩 뽑힘
			StringTokenizer del = new StringTokenizer(no,"/");
			Map map1 = new HashMap();
			int i=0;
			while(del.hasMoreTokens()){
				String val = del.nextToken();
				if(i%2==0){
					map1.put("movie_no", val);
				}
				else{
					map1.put("theater_no", val);
					System.out.println("영화번호, 영화관 번호"+map1.toString());
					adminService.screeningMovieDel(map1);
				}			
				i++;
			}
		} catch (SQLException e) {
			e.printStackTrace();
		} //지역정보		
		return new ModelAndView("JsonView");
	}
	/**
	 * 영화검색 -5/11 아영
	 */
	public ModelAndView searchMovie(HttpServletRequest request, HttpServletResponse reponse){
		String method=request.getParameter("method");
		String search_title=request.getParameter("search_title");
		ArrayList<MovieVO> list=null;
		try {
			list = adminService.getSearchMovie(method,search_title);
			
		} catch (SQLException e) {
			e.printStackTrace();
		}	
		return new ModelAndView("JsonView","list",list);
	}
	/**
	 * 상영표등록시 날짜 체크
	 */
	public ModelAndView todayCheck(HttpServletRequest request, HttpServletResponse reponse){
		System.out.println("todayCheck join.. day : "+request.getParameter("day"));
		boolean flag = adminService.todayCheck(request.getParameter("day"));
		return new ModelAndView("JsonView","flag",flag);
	}	
}
